<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE html>
<!--[if IE 9 ]><html class="ie9"><![endif]-->
<head>
<meta name="viewport"
	content="width=device-width, initial-scale=1.0, maximum-scale=1.0" />
<meta name="format-detection" content="telephone=no">
<meta charset="UTF-8">
<meta name="description" content="Violate Responsive Admin Template">
<meta name="keywords" content="Super Admin, Admin, Template, Bootstrap">

<title>统计界面</title>

<!-- CSS -->
<link href="<%=path %>/css/bootstrap.min.css" rel="stylesheet">
<!--         <link href="css/bootstrap-datetimepicker.min.css" rel="stylesheet">  -->
<link href="<%=path %>/css/animate.min.css" rel="stylesheet">
<link href="<%=path %>/css/font-awesome.min.css" rel="stylesheet">
<link href="<%=path %>/css/form.css" rel="stylesheet">
<link href="<%=path %>/css/calendar.css" rel="stylesheet">
<link href="<%=path %>/css/media-player.css" rel="stylesheet">
<link href="<%=path %>/css/style.css" rel="stylesheet">
<link href="<%=path %>/css/icons.css" rel="stylesheet">
<link href="<%=path %>/css/generics.css" rel="stylesheet">
<style>
.c{
display:inline;
}
</style>

</head>
<body id="skin-blur-violate">
	<header id="header" class="media">
		<a href="" id="menu-toggle"></a> <a class="logo pull-left"
			href="">CP统计信息</a>

		<div class="media-body">
			<div class="media" id="top-menu">
				<div id="time" class="pull-right">
					<span id="hours"></span> : <span id="min"></span> : <span id="sec"></span>
				</div>
			</div>
		</div>
	</header>

	<div class="clearfix"></div>

	<section id="main" class="p-relative" role="main">

		<!-- Sidebar -->

		<!-- Content -->
		<section id="content" class="container">
			<h4 class="page-title">渠道收益统计
			<a  href="javascript:logout();" style="position:absolute;right:10px;z-index:999;">登出</a>
			</h4>
<!-- 			<input type="text" id="endTime" class="form-control" -->
<!-- 				value="" onchange="timeInfo();" -->
<!-- 				onFocus="WdatePicker({dateFmt:'yyyy-MM-dd'})" /> -->
			
			<br>
			<div class="form-group">
				&nbsp;&nbsp;&nbsp;
				<label for="name">日期：</label> 
				<input type="text"  style="width:150px;" id="startTime" class="form-control c" value="${startTime}" 
				onFocus="WdatePicker({maxDate:'#F{$dp.$D(\'endTime\')||\'2020-10-01\'}',maxDate:'%y-%M-%d'})"/>
				<input type="text" style="width:150px;" id="endTime" class="form-control c" value="${endTime}" 
				onFocus="WdatePicker({minDate:'#F{$dp.$D(\'startTime\')}',maxDate:'%y-%M-%d'})"/>
				&nbsp;&nbsp;&nbsp;
				<label for="name">渠道号：</label> 
				<select class="form-control c" id="channelId" name="channelId" style="width:200px;">
						<option value="-1" selected="selected">--请选择渠道--</option>
						<c:forEach items="${list}" var="dic">
						<option value="${dic}">${dic}</option>
						</c:forEach>
				</select>
				&nbsp;&nbsp;&nbsp;
				<a data-dismiss="modal" class="btn btn-primary btn-sm"
				href="javascript:void(0);" onclick="searchInfo();">查询</a>
			</div>
			<!-- Table Hover -->
			<div class="block-area" id="tableHover">
				<h3 class="block-title">数据信息表</h3>
				<div class="table-responsive overflow">
					<table class="table table-bordered table-hover tile">
						<thead>
							<tr>
								<th>渠道Id</th>
<!-- 								<th>业务分成模式</th> -->
								<th>新增</th>
								<th>付费</th>
<!-- 								<th>查询日期</th> -->
							</tr>
						</thead>
						<tbody id="ChanneView">
<!-- 							<tr> -->
<!-- 								<td>1</td> -->
<!-- 								<td>Jhon</td> -->
<!-- 								<td>Makinton</td> -->
<!-- 								<td>@makinton</td> -->
<!-- 							</tr> -->
<!-- 							<tr> -->
<!-- 								<td>2</td> -->
<!-- 								<td>Malinda</td> -->
<!-- 								<td>Hollaway</td> -->
<!-- 								<td>@hollway</td> -->
<!-- 							</tr> -->
<!-- 							<tr> -->
<!-- 								<td>3</td> -->
<!-- 								<td>Wayn</td> -->
<!-- 								<td>Parnel</td> -->
<!-- 								<td>@wayne123</td> -->
<!-- 							</tr> -->
						</tbody>
					</table>
				</div>
			</div>
		</section>
		<br />
		<br />
	</section>
	<textarea style="display: none;" id="Template-ChanneView">
	{#foreach $T.list as Row}
    <tr>
		<td>{$T.Row.channelId}</td>
        <td>{$T.Row.userCount}</td>
        <td>
			{#if $T.Row.shareType==1}
				{#if $T.Row.incomeDisplay==0} {#else}{$T.Row.incomeDisplay}{#/if}
			{#/if}
			{#if $T.Row.shareType==2}
				{$T.Row.incomeDisplay}
			{#/if}
        </td>
	</tr>
    {#/for}
	<tr>
		<td>总计</td>
		<td style="font-weight:bold;"><font color="red"><span>{$T.total.userCount}</span></font></td> 
		<td style="font-weight:bold;"><font color="red"><span id="userSumCount">{$T.total.incomeDisplay}</span></font></td>  	
	</tr>
</textarea>	
	

	<!-- Javascript Libraries -->
	<!-- jQuery -->
	<script type="text/javascript" src="<%=path %>/js/jquery-1.11.1.js"></script>
	<!-- jQuery Library -->
	<!-- Bootstrap -->
	<script type="text/javascript" src="<%=path %>/js/bootstrap.min.js"></script>
<!-- 	日历 -->
	<script type="text/javascript" src="<%=path %>/js/My97DatePicker/WdatePicker.js"></script>
<!-- 	分页 ajax -->
	<script type="text/javascript" src="<%=path %>/js/myPageBar/myPageBar-1.0.js"></script>
	
	
	<!-- UX -->
	<script src="<%=path %>/js/scroll.min.js"></script>
	<!-- Custom Scrollbar -->
	<!-- Other -->
	<script src="<%=path %>/js/calendar.min.js"></script>
	<!-- Calendar -->
	<script src="<%=path %>/js/feeds.min.js"></script>
	<!-- News Feeds -->
<!-- 	All JS functions -->
	<script src="<%=path %>/js/functions.js"></script>
	<script src="<%=path %>/js/jtemplates.js"></script>
	<script src="<%=path %>/js/matrix.js"></script>
	
	
	<script type="text/javascript">
		window.onload = function() {
			document.getElementById("menu-toggle").click();
			$("#menu-toggle").fadeOut("fast");
		}
		
		var pageBar;	
		$(function() {
			var startTime = $("#startTime").val();
			var endTime = $("#endTime").val();
			pageBar = $(".page")
					.myPageBar(
							{
								currPage : 1,
								pageSize : 10,
								ajax : {
									url : "<%=path%>/Statistics/incomViewlistSelect",
									param : "pageSize=20&channelId=-1&startTime="+startTime+"&endTime="+endTime,
									callback : ajaxCallBack,
									ajaxStart : function() {
										var h = "<tr><td colspan='8' style='text-align:center' >"
												+ "<img width='60' height='60' src='images/load.jpg'/></td></tr>";
										$("#companyList").html(h);
									},
									ajaxStop : function() {
										$("#companyList").empty();
									},
								},
							});
		});

		function ajaxCallBack(data) {
			if ((!data.list)||data.list.length == 0) {
				$("#ChanneView")
						.html(
								"<tr><td colspan='8' style='text-align:center'>没有数据</td></tr>");
				return;
			}
			$("#ChanneView").setTemplateElement("Template-ChanneView").processTemplate(data);
		}


		function searchInfo(){
			var param = "pageSize=10";
			var channelId = $("#channelId").val();
			var startTime = $("#startTime").val();
			var endTime = $("#endTime").val();
			if(startTime == "" || endTime == ""){
				alert("请先选择时间");
				return;
			}
			var time = getNowFormatDate();
			
			if(endTime == time){
				if(channelId == "-1"){
					alert("查询当天数据请选择渠道");
					return;
				}
			}
			
			param+="&startTime="+startTime+"&endTime="+endTime+"&channelId="+channelId;
			pageBar.onLoad({param:param});
		}

		function getNowFormatDate() {
		    var date = new Date();
		    var seperator1 = "-";
		    var seperator2 = ":";
		    var year = date.getFullYear();
		    var month = date.getMonth() + 1;
		    var strDate = date.getDate();
		    if (month >= 1 && month <= 9) {
		        month = "0" + month;
		    }
		    if (strDate >= 0 && strDate <= 9) {
		        strDate = "0" + strDate;
		    }
		    var currentdate = year + seperator1 + month + seperator1 + strDate;
		    return currentdate;
		}	
		function logout(){
			$.get("<%=path%>/logout",
					function(data){
						window.location.href=$("base").attr("href")+"login.jsp";
					});
		}
	</script>
</body>
</html>

